// import { url } from '@/config';
// var request = window.axios;
// let url="/api/blade-visual"
import request from '@/router/axios';

export const getRoleList = (params = {}) => request({
    url: '/api/Role/List',
    method: 'get',
    params: Object.assign(params, {
    })
});

export const addRole = (data = {}) => request({
    url: '/api/Role/Add',
    method: 'post',
    data: data
});

export const deleteRole = (params = {}) => request({
    url: '/api/Role/Delete',
    method: 'post',
    params: Object.assign(params, {
    }),
});

export const editRole = (data = {}) => request({
    url: '/api/Role/Edit',
    method: 'post',
    data: data,
});

export const getUserById = (params = {}) => request({
    url: '/api/User/GetUserByIdOrName',
    method: 'get',
    params: Object.assign(params, {
    })
});

export const getUserList = (params = {}) => request({
    url: '/api/User/List',
    method: 'get',
    params: Object.assign(params, {
    })
});
export const getDeptUserList = (params = {}) => request({
    url: '/api/User/ListOfDept',
    method: 'get',
    params: Object.assign(params, {
    })
});

export const addUser = (data = {}) => request({
    url: '/api/User/Add',
    method: 'post',
    data: data
});

export const deleteUser = (params = {}) => request({
    url: '/api/User/Delete',
    method: 'post',
    params: Object.assign(params, {
    }),
});

export const editUser = (data = {}) => request({
    url: '/api/User/Edit',
    method: 'post',
    data: data,
});

export const resetUserPassword = (params = {}) => request({
    url: '/api/User/ResetPassword',
    method: 'post',
    params: Object.assign(params, {
    }),
});

export const changeUserPassword = (params = {}) => request({
    url: '/api/User/ChangePassword',
    method: 'post',
    params: Object.assign(params, {
    }),
});

export const getTenantList = (params = {}) => request({
    url: '/api/Tenant/List',
    method: 'get',
    params: Object.assign(params, {
    })
});

export const addTenant = (params = {}) => request({
    url: '/api/Tenant/Add',
    method: 'post',
    params: params
});

export const deleteTenant = (params = {}) => request({
    url: '/api/Tenant/Delete',
    method: 'post',
    params: Object.assign(params, {
    }),
});

export const editTenant = (data = {}) => request({
    url: '/api/Tenant/Update',
    method: 'post',
    data: data,
});

export const getAuthorityList = (params = {}) => request({
    url: '/api/Authority/Get',
    method: 'get',
    params: Object.assign(params, {
    })
});

export const getAppAuthorityList = (params = {}) => request({
    url: '/api/Authority/GetAppAuth',
    method: 'get',
    params: Object.assign(params, {
    })
});

//根据角色ID获得角色
export const getRoleByID = (params = {}) => request({
    url: '/api/Role/Get',
    method: 'get',
    params: Object.assign(params, {
    })
});

//更新用户角色
export const updateUser = (data = {}) => request({
    url: '/api/Role/UpdateUser',
    method: 'post',
    data: data
});

//获得机器码
export const getMachineID = (params = {}) => request({
    url: '/api/lic/MachineID',
    method: 'get',
    params: Object.assign(params, {
    })
});

//添加license
export const addLicense = (params = {}) => request({
    url: '/api/lic/Add',
    method: 'post',
    params: Object.assign(params, {
    })
});

//获得license列表
export const getLicenseList = () => request({
    url: '/api/lic/List',
    method: 'get'
});

//启用license
export const enableLicense = (params = {}) => request({
    url: '/api/lic/Enable',
    method: 'post',
    params: Object.assign(params, {
    })
});

//获得租户账号信息
export const getTenantInfo = (params = {}) => request({
    url: '/api/Tenant/Info/GetByTenantId',
    method: 'get',
    params: Object.assign(params, {
    })
});

//修改租户账号信息
export const updateTenantInfo = (data) => request({
    url: '/api/Tenant/Info/Update',
    method: 'post',
    data: data
});


export function getAllAppList() {
    return new Promise((resolve, reject) => {
        request({
            url:'/api/Cgs/Portal/Visual/ListAll',
            method: 'get'
        }).then((result) => {
            if(result?.data.success){
                resolve(result.data.data)
            }else{
                reject(new Error("未请求到应用列表"))
            }
        }).catch((err) => {
            reject(err)
        });
    })
}